/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

var showallfriend = 1;

function makeObjRequest(){
    var xmlhttp;
    if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
    }
    else
    {// code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    return xmlhttp;
}

function chatbox(){
    var val = "";
    var nodelist = document.getElementsByName('inputchatboxtext');
    val = nodelist[0].value;
    if(val != ""){
        if(val.toString().charAt(0) == '/'){
            document.getElementById('feedbackchatbox').innerHTML = "processing command..."
            var req = makeObjRequest();
            req.onreadystatechange = function(){
                if (req.readyState==4 && req.status==200)
                {
                    document.getElementById("feedbackchatbox").innerHTML=req.responseText;
                    setTimeout(function(){
                        document.getElementById("feedbackchatbox").innerHTML=""
                    }, 5000)
                //setTimeout(loadloginas(loginuser), 1000);
                }
            }
            req.open("GET","Command?value="+val, true);
            req.send();
        }else{
            document.getElementById('feedbackchatbox').innerHTML = "buat chat text gan..."
        }
        document.getElementsByName('inputchatboxtext')[0].value = "";
    }
}

function retrievefriend(){
    var req = makeObjRequest();
    req.onreadystatechange = function(){
        if (req.readyState==4 && req.status==200)
        {
            document.getElementById("friendlist").innerHTML=req.responseText;
            setTimeout(function(){
                retrievefriend();
            }, 2234)
        //setTimeout(loadloginas(loginuser), 1000);
        }
    }
    req.open("GET","FriendHandler?value="+showallfriend, true);
    req.send();
}

function changemodefriend(){
    if(showallfriend == 0){
        showallfriend = 1;
    }else{
        showallfriend = 0;
    }
}

function retriveCategoryList(){
    var req = makeObjRequest();
    req.onreadystatechange = function(){
        if (req.readyState==4 && req.status==200)
        {
            document.getElementById("roomlist").innerHTML=req.responseText;
            retrievefriend();
        //setTimeout(loadloginas(loginuser), 1000);
        }
    }
    req.open("GET","RoomListHandler", true);
    req.send();
}